<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" action="${web_domain}/mall/seckillSession/list" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='ccmc'/></label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" placeholder="<fmt:message key='hdccmc'/>" value="<c:if test='${params.name !=null}'>${params.name}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>


                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='sj'/></label>
                        <div class="layui-inline">
                            <input type="text" class="layui-input" style="width: 100px" readonly name="seckillBeginTime" id="seckillBeginTime" value="${params.seckillBeginTime}">
                            <span class="layui-inline">-</span>
                            <input type="text" class="layui-input" style="width: 100px" name="seckillEndTime" readonly id="seckillEndTime" value="${params.seckillEndTime}">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 80px;"><fmt:message key='hdzt'/></label>
                        <div class="layui-input-inline">
                            <select name="isValidity">
                                <option value="0"><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.isValidity == 1}">selected</c:if> ><fmt:message key='wks'/></option>
                                <option value="2" <c:if test="${params.isValidity == 2}">selected</c:if> ><fmt:message key='hdks'/></option>
                                <option value="3" <c:if test="${params.isValidity == 3}">selected</c:if> ><fmt:message key='hdjs'/></option>
                            </select>
                        </div>
                    </div>

                    <!-- 需要排序的字段 -->
                    <%--<input type="hidden" class="feijin-orderby" name="orderByCreateTime" id="orderByCreateTimeParams" value="${params.orderByCreateTime}"/>--%>
                    <%--<input type="hidden" class="feijin-orderby" name="orderByStore" id="orderByStoreParams" value="${params.orderByStore}"/>--%>
                    <%--<input type="hidden" class="feijin-orderby" name="orderByPrice" id="orderByPriceParams" value="${params.orderByPrice}"/>--%>
                    <%--<input type="hidden" class="feijin-orderby" name="orderBySalesVolume" id="orderBySalesVolumeParams" value="${params.orderBySalesVolume}"/>--%>
                    <!-- 需要排序的字段 -->
                    <%--<input type="hidden" name="status" value="${params.status}"/>--%>

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-normal" id="add"><i class="layui-icon">&#xe61f;</i> <fmt:message key='tj'/></a>

            <table class="layui-table" lay-size="sm">
                <thead>
                <%--<th width="5%"><input id="checkboxs" type="checkbox" value="${item.id}" lay-ignore lay-skin="primary"/></th>--%>
                <th><fmt:message key='ccmc'/></th>
                <th><fmt:message key='msrq'/></th>
                <th><fmt:message key='kssj'/></th>
                <th><fmt:message key='jssj1'/></th>
                <th><fmt:message key='bmjzsj'/></th>
                <th><fmt:message key='zt'/></th>
                <th><fmt:message key='hdzt'/></th>
                <th><fmt:message key='cjsj'/></th>
                <th><fmt:message key='cz'/></th>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${item.name}</td>
                        <td>${item.seckillTime }</td>
                        <td>${item.seckillBeginTime }</td>
                        <td>${item.seckillEndTime }</td>
                        <td>${item.applyDeadline }</td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq 1}"><fmt:message key='xj'/></c:when>
                                <c:when test="${item.status eq 2}"><fmt:message key='sc'/></c:when>
                            </c:choose>
                        </td>
                        <td>
                            <c:choose>
                                <c:when test="${item.isValidity eq 1}"><fmt:message key='wks'/></c:when>
                                <c:when test="${item.isValidity eq 2}"><fmt:message key='jxz'/></c:when>
                                <c:when test="${item.isValidity eq 3}"><fmt:message key='yjs'/></c:when>
                            </c:choose>
                        </td>
                        <td>${item.createTime }</td>
                        <td>
                            <div class="layui-btn-container">

                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='ck'/></a>

                                <c:if test="${item.isValidity == 1}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-modify"><fmt:message key='bj'/></a>
                                </c:if>

                                <c:choose>
                                    <c:when test="${item.status eq 1}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-putaway"><fmt:message key='sj'/></a>
                                    </c:when>
                                    <c:when test="${item.status eq 2}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs layui-btn-danger feijin-soldOut"><fmt:message key='xj'/></a>
                                    </c:when>
                                </c:choose>

                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    $(function () {

        layui.use(['form', 'laydate'], function () {

            var form = layui.form;
            var laydate = layui.laydate;

            laydate.render({
                elem: "#seckillBeginTime",
                type:'date'
            });

            laydate.render({
                elem: "#seckillEndTime",
                type:'date'
            });

        });

        //下架
        $(".feijin-soldOut").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrxjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/seckillSession/soldOut",
                    data: {id: id}
                });
            });
        });

        //上架
        $(".feijin-putaway").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrsjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/seckillSession/putaway",
                    data: {id: id}
                });
            });
        });


        //查看详情
        $(".feijin-detail").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='ckxq'/>'
                , content: '${web_domain}/mall/seckillSession/' + id + '/detail'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh'/>']
            });
        });

        //添加
        $("#add").click(function () {
            layer.open({
                type: 2
                , title: '<fmt:message key='tjmscc'/>'
                , content: '${web_domain}/mall/seckillSession/create'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='bc'/>', '<fmt:message key='qx'/>']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

        //编辑
        $(".feijin-modify").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='bjmscc'/>'
                , content: '${web_domain}/mall/seckillSession/' + id + '/modify'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='bc'/>', '<fmt:message key='qx'/>']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

    });
</script>
</body>
</fmt:bundle>
</html>
